Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
node-notifier
Advanced tools
A Node.js module for sending notifications on native Mac, Windows (post and pre 8) and Linux (or Growl as fallback)
The node-notifier package is a Node.js module for sending native notifications on different platforms like Windows, Mac, and Linux. It provides an easy-to-use API to show system notifications using the native notification system of the operating system.
Cross-platform notifications
This feature allows you to send desktop notifications across different operating systems. The code sample shows how to send a simple notification with a title and a message.
const notifier = require('node-notifier');
notifier.notify({
title: 'My notification',
message: 'Hello, this is a notification!'
});
Notification actions
This feature allows you to listen for user interactions with the notification, such as clicking on it. The code sample demonstrates how to handle a click event on the notification.
const notifier = require('node-notifier');
notifier.notify({
title: 'My notification',
message: 'Click to perform an action',
wait: true
}, (err, response, metadata) => {
if (metadata.activationType === 'clicked') {
console.log('Notification clicked!');
}
});
Custom notification sound
This feature allows you to customize the notification sound and appearance. The code sample shows how to send a notification with a custom sound and icon.
const notifier = require('node-notifier');
notifier.notify({
title: 'My notification',
message: 'With a custom sound!',
sound: true, // Only Notification Center or Windows Toasters
appIcon: '/path/to/icon.png', // Absolute path (doesn't work on balloons)
contentImage: '/path/to/image.png' // Absolute Path to Attached Image (Content Image)
});
A package specifically designed for Electron applications to show desktop notifications. It is similar to node-notifier but tailored for the Electron environment, which means it might not be suitable for non-Electron Node.js applications.
This package allows you to send notifications using the Pushover service. It differs from node-notifier in that it requires an internet connection and uses the Pushover API to send messages to devices, whereas node-notifier works offline and uses the native OS notification systems.
Toastr is a Javascript library for non-blocking notifications. It is designed for web applications and provides in-browser notifications as opposed to the system-level notifications provided by node-notifier.
A node module for sending notification using node. Uses terminal-notifier on mac, notify-send for Linux, toaster for Windows 8, balloons for Windows pre 8 or Growl for others.
If using Linux, notify-osd
must be installed on your system.
For Mac, terminal-notifier, comes
bundled in the module. So on Mac, not additional installations is necessary.
This also goes for native Windows (version >=8) as well, where toaster.exe is bundled. Note, for native Windows notifications a toast must have a shortcut installed (though not necessarily pinned) to the Start screen or in the Apps view, but this happens automatically.
Growl takes precidence over Windows balloons. So if Growl is active, growl is used, if not, balloons are shown.
If no of the other requirements are met, node-notifier will use Growl. You have to have Growl installed on your system. See Growl for Windows or Growl for Mac.
See documentation and flow chart for reporters
$ npm install node-notifier
var Notification = require('node-notifier');
var notifier = new Notification();
notifier.notify({
title: 'My awesome title',
message: 'Hello from node, Mr. User!'
});
Notification
also has specifications for all types of notifications, to be used
manually.
Example:
var nn = require('node-notifier');
new nn.NotificationCenter().notify();
new nn.NotifySend().notify();
new nn.WindowsToaster().notify(options);
new nn.WindowsBalloon().notify(options);
new nn.Growl().notify(options);
Common options between the modules (i.e. icon
) is mapped. This means,
if you are using a Mac and someone on your project is using Linux, you
can both see icons.
Same usage and parameter setup as terminal-notifier.
Native Notification Center requires Mac OS X version 10.8 or higher. If you have earlier versions, Growl will be the fallback. If Growl isn't installed, an error will be thrown.
3.0.0
.Parsing of output given by terminal-notifier is removed as of node-notifier 3.0.0
.
You can still use both remove
and list
but the output given will not be parsed into a object.
See removed documentation for pre version 3.0.0
in Deprecated documentation
Where terminal-notifier say to use the -message
option, you can do this in node-notifier
var Notification = require('node-notifier');
var notifier = new Notification();
notifier.notify({
message: 'Hello World'
});
You can specify the second argument as a callback for getting error
and response
.
var Notification = require('node-notifier');
var notifier = new Notification({
// Options passed to Growl if fallback
});
notifier.notify({
title: 'My application',
message: 'New notification'
}, function(error, response) {
console.log(response);
});
As of version 3.0.0
, you can also specify image used as icon or content image. For Mac OS notifications, requires 10.9.
notifier.notify({
"title": "Phil Coulson",
"subtitle": "Agent of S.H.I.E.L.D.",
"message": "If I come out, will you shoot me? 'Cause then I won't come out.",
"sound": "Funk", // case sensitive
"contentImage": __dirname + "/coulson.jpg",
"appIcon": __dirname + "/coulson.jpg",
"open": "file://" + __dirname + "/coulson.jpg"
});
See terminal-notifier for more options.
var Notification = require('node-notifier');
var notifier = new Notification({
// Options passed to Growl if fallback
});
notifier.notify({
title: 'Foo',
message: 'Hello World',
icon: __dirname + "/coulson.jpg",
// .. and other notify-send flags
});
See flags and options on the man pages
var Notification = require('node-notifier');
var notifier = new Notification({
// Options passed to Growl if fallback
});
notifier.notify({
title: 'Foo',
message: 'Hello World',
icon: __dirname + "/coulson.jpg"
});
For earlier Windows versions, the taskbar balloons are used. For balloons a great project called notifu is used.
var Notification = require('node-notifier');
var notifier = new Notification({
// Options passed to Growl if fallback
});
notifier.notify({
p: 'Foo', // Title (can use title:)
m: 'Hello World', // Message (can use message:)
d: 1000 // Show for 1000 ms
});
See full usage on the project homepage: notifu.
var Notification = require('node-notifier');
var notifier = new Notification({
name: 'Growl Name Used' // Defaults as 'Node'
});
notifier.notify({
title: 'Foo',
message: 'Hello World',
icon: fs.readFileSync(__dirname + "/coulson.jpg")
// and other growl options like sticky etc.
});
See more information for constructor options in growler.
FAQs
A Node.js module for sending notifications on native Mac, Windows (post and pre 8) and Linux (or Growl as fallback)
We found that node-notifier demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.